// SPDX-License-Identifier: GPL-2.0-only
/*
 * Copyright (c) Huawei Technologies Co., Ltd. 2023-2023. All rights reserved.
 * Author: Huawei OS Kernel Lab
 * Create: Thu Aug 15 16:14:23 2023
 */

#include <linux/mm.h>

struct page *(*g_pagecache_alloc_fn)(gfp_t gfp_mask, unsigned int order) = NULL;

void liblinux_enable_page_cache(
		struct page *(*pagecache_alloc_fn)(gfp_t gfp_mask, unsigned int order))
{
	g_pagecache_alloc_fn = pagecache_alloc_fn;
}
EXPORT_SYMBOL(liblinux_enable_page_cache);

struct page *__page_cache_alloc(gfp_t gfp)
{
	if (g_pagecache_alloc_fn)
		return g_pagecache_alloc_fn(gfp, 0);
	else
		return alloc_pages_cache(gfp, 0);
}
